package com.yanqu.xiuxian.crosssystem.manger.elementalbonds.enums;

import com.yanqu.xiuxian.config.elementalbonds.ElementalBondsSkillConfig;
import com.yanqu.xiuxian.config.elementalbonds.enums.*;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.data.ElementalBondsGameData;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.data.ElementalBondsPlayerData;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.entity.ElementalBondsBlock;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.entity.ElementalBondsOperateEffect;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.logic.ElementalBondsBlockLogic;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.logic.ElementalBondsCardLogic;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.logic.ElementalBondsMoveLogic;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.logic.ElementalBondsSceneLogic;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.param.ElementalBondsMoveParam;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.param.ElementalBondsSkillParam;
import com.yanqu.xiuxian.crosssystem.manger.elementalbonds.result.ElementalBondsOperateResult;
import com.yanqu.xiuxian.server.protocol.GameErrorCode;

import java.util.*;

public enum ElementalBondsSkillType {

    NONE(0, "无", "无") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            return Collections.emptySet();
        }
    },

    SKILL_1001(1001, "刷新", "无") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 重排
            ElementalBondsBlockLogic.rearrange(elementalBondsGameData, random);
            List<ElementalBondsBlock> allElementalBondsBlockList = new ArrayList<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : elementalBondsGameData.getBlockList()) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    allElementalBondsBlockList.add(elementalBondsBlock.clone());
                }
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, allElementalBondsBlockList));

            return Collections.emptySet();
        }
    },
    SKILL_1002(1002, "锤子", "无") {
        @Override
        public int check(ElementalBondsGameData elementalBondsGameData, ElementalBondsSkillParam elementalBondsSkillParam, ElementalBondsOperateResult elementalBondsOperateResult) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            if (!ElementalBondsBlockLogic.exist(blockList, elementalBondsSkillParam.getFromX(), elementalBondsSkillParam.getFromY())) {
                return GameErrorCode.E_ELEMENTAL_BONDS_POS_NO_EXIST;
            }
            int ret = ElementalBondsSceneLogic.scene_07_checkChooseBlock(elementalBondsGameData, elementalBondsSkillParam, false);
            if (ret != GameErrorCode.E_SUCCESS_VALUE) {
                return ret;
            }
            return ElementalBondsCardLogic.check_23(elementalBondsGameData, elementalBondsSkillParam);
        }

        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
            // 选择格子
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            if (ElementalBondsBlockLogic.exist(blockList, elementalBondsSkillParam.getFromX(), elementalBondsSkillParam.getFromY())) {
                elementalBondsBlockSet.add(blockList.get(elementalBondsSkillParam.getFromY()).get(elementalBondsSkillParam.getFromX()));
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, new ArrayList<>(elementalBondsBlockSet)));

            return elementalBondsBlockSet;
        }
    },
    SKILL_1003(1003, "极速充能", "没效果") {
        @Override
        public int check(ElementalBondsGameData elementalBondsGameData, ElementalBondsSkillParam elementalBondsSkillParam, ElementalBondsOperateResult elementalBondsOperateResult) {
            ElementalBondsMoveParam elementalBondsMoveParam = new ElementalBondsMoveParam(elementalBondsSkillParam);
            return ElementalBondsMoveLogic.check(elementalBondsGameData, elementalBondsMoveParam, elementalBondsOperateResult);
        }

        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 改成移动类型再移动
            elementalBondsOperateResult.setElementalBondsOperateType(ElementalBondsOperateType.MOVE);

            // 交换方块消除
            ElementalBondsMoveParam elementalBondsMoveParam = new ElementalBondsMoveParam(elementalBondsSkillParam);
            ElementalBondsMoveLogic.move(elementalBondsMoveParam, elementalBondsGameData, elementalBondsOperateResult, elementalBondsPlayerData,
                    random, -1, roomRound, turnPlayer);
            ElementalBondsSceneLogic.operateEnd(random, elementalBondsGameData, elementalBondsOperateResult);

            // 改回盘面技能类型
            elementalBondsOperateResult.setElementalBondsOperateType(ElementalBondsOperateType.USE_SKILL);

            return Collections.emptySet();
        }
    },
    SKILL_1004(1004, "棋盘", "效果1：所有变了的格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 配置
            long colorNum = elementalBondsSkillConfig.getSkillParamList().get(0);

            // 随机2色
            List<Integer> colorList = new ArrayList<>();
            for (ElementalBondsColorType elementalBondsColorType : ElementalBondsColorType.values()) {
                if (elementalBondsColorType != ElementalBondsColorType.NONE
                        && elementalBondsColorType != ElementalBondsColorType.RED
                        && elementalBondsColorType != ElementalBondsColorType.BLUE) {
                    colorList.add(elementalBondsColorType.getType());
                }
            }
            List<Integer> chooseList = new ArrayList<>();
            for (int i = 0; i < colorNum; i++) {
                if (!colorList.isEmpty()) {
                    chooseList.add(colorList.remove(random.nextInt(colorList.size())));
                } else {
                    break;
                }
            }

            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
            int index = 0;
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    index++;
                    if (elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL
                            || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB) {
                        elementalBondsBlock.setColor(chooseList.get(index % chooseList.size()));
                        ElementalBondsSceneLogic.scene_12_checkEffectChange(elementalBondsBlock, elementalBondsGameData);
                        elementalBondsBlockSet.add(elementalBondsBlock);
                    }
                }
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, new ArrayList<>(elementalBondsBlockSet)));

            return Collections.emptySet();
        }
    },
    SKILL_1005(1005, "制造星星", "效果1：生成的星星格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 配置
            long num = elementalBondsSkillConfig.getSkillParamList().get(0);

            // 获取可选方块
            List<ElementalBondsBlock> canRandomList = new ArrayList<>();
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    if (elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL) {
                        canRandomList.add(elementalBondsBlock);
                    }
                }
            }

            // 打乱
            Collections.shuffle(canRandomList, random);

            // 取方块变流星
            List<ElementalBondsBlock> chooseList = new ArrayList<>();
            for (int i = 0; i < num && i < canRandomList.size(); i++) {
                ElementalBondsBlock elementalBondsBlock = canRandomList.get(i);
                elementalBondsBlock.setElementalBondsBlockType(ElementalBondsBlockType.METEOR_BOMB);
                chooseList.add(elementalBondsBlock);
            }

            // 添加效果
            if (!chooseList.isEmpty()) {
                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, chooseList));
            }

            return Collections.emptySet();
        }
    },
    SKILL_1006(1006, "消除十字", "效果1：十字范围的格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            // 横
            if (elementalBondsSkillParam.getFromY() < blockList.size()) {
                elementalBondsBlockSet.addAll(blockList.get(elementalBondsSkillParam.getFromY()));
            }
            // 竖
            if (elementalBondsSkillParam.getFromX() < blockList.get(0).size()) {
                for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                    elementalBondsBlockSet.add(elementalBondsBlockList.get(elementalBondsSkillParam.getFromX()));
                }
            }

            // 添加效果
            if (!elementalBondsBlockSet.isEmpty()) {
                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, new ArrayList<>(elementalBondsBlockSet)));
            }

            return elementalBondsBlockSet;
        }
    },
    SKILL_1007(1007, "迷你印刷", "效果1：左移 效果2：右移 参考：毕升技能") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            // 选择的列
            int chooseX = elementalBondsSkillParam.getFromX();
            if (chooseX < 0 || chooseX >= blockList.get(0).size()) {
                return Collections.emptySet();
            }

            // 方向
            int direction;
            if (chooseX == 0) {
                direction = 1;
            } else if (chooseX == blockList.get(0).size() - 1) {
                direction = -1;
            } else {
                direction = random.nextInt(1000) < 500 ? -1 : 1;
            }

            // 复制开始
            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                ElementalBondsBlock fromElementalBondsBlock = elementalBondsBlockList.get(chooseX);
                int toX = chooseX + direction;
                ElementalBondsBlock toElementalBondsBlock = elementalBondsBlockList.get(toX);

                if (fromElementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL
                        || fromElementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB) {
                    if (toElementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL
                            || toElementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB) {

                        ElementalBondsBlock clone = fromElementalBondsBlock.clone();
                        clone.setElementalBondsBlockEffectList(new ArrayList<>()); // 效果不能复制
                        clone.setX(toX);
                        blockList.get(clone.getY()).set(clone.getX(), clone);

                        ElementalBondsBlock tmp = fromElementalBondsBlock.clone();
                        tmp.setElementalBondsBlockEffectList(new ArrayList<>()); // 给个假效果
                        elementalBondsBlockSet.add(tmp);
                    }
                }
            }

            // 添加效果
            if (!elementalBondsBlockSet.isEmpty()) {
                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, direction == 1 ? 2 : 1, new ArrayList<>(elementalBondsBlockSet)));
            }

            return Collections.emptySet();
        }
    },
    SKILL_1008(1008, "迷你飞刀", "效果1：要消除的格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            // 找可以随机的方块
            Set<Integer> colorSet = new HashSet<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    if (elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL
                            || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB
                            || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.SPECIAL) {
                        colorSet.add(elementalBondsBlock.getColor());
                    }
                }
            }
            colorSet.remove(0);
            if (colorSet.isEmpty()) {
                return Collections.emptySet();
            }

            // 随机一个出来
            List<Integer> colorList = new ArrayList<>(colorSet);
            int index = random.nextInt(colorList.size());
            int color = colorList.get(index);

            // 红釉青花特殊处理
            ElementalBondsSceneLogic.scene_08_changeColor(elementalBondsGameData, color);

            // 消除同色
            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    if (elementalBondsBlock.getColor() == color) {
                        if (elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL
                                || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB
                                || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.SPECIAL) {
                            elementalBondsBlockSet.add(elementalBondsBlock);
                        }
                    }
                }
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, new ArrayList<>(elementalBondsBlockSet)));

            return elementalBondsBlockSet;
        }
    },
    SKILL_1009(1009, "迷你机械手", "效果1：参考鲁班") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 参数
            long canMoveTimes = elementalBondsSkillConfig.getSkillParamList().get(0);

            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            Set<ElementalBondsBlock> movedElementalBondsBlockSet = new HashSet<>();

            int moveTimes = 0;
            for (int times = 0; times < 10; times++) { // 最多检查10轮，如果本轮没有可移动的，下面会break
                int curSize = movedElementalBondsBlockSet.size();

                if (moveTimes >= canMoveTimes) {
                    break;
                }
                for (int y = 0; y < blockList.size(); y++) {
                    if (moveTimes >= canMoveTimes) {
                        break;
                    }
                    for (int x = 0; x < blockList.get(y).size(); x++) {
                        if (moveTimes >= canMoveTimes) {
                            break;
                        }

                        ElementalBondsBlock elementalBondsBlock = blockList.get(y).get(x);
                        if (movedElementalBondsBlockSet.contains(elementalBondsBlock)) {
                            continue;
                        }

                        // 跟右边交换
                        int rightX = x + 1;
                        if (ElementalBondsBlockLogic.exist(blockList, rightX, y) && !movedElementalBondsBlockSet.contains(blockList.get(y).get(rightX))) {
                            ElementalBondsBlock rightElementalBondsBlock = blockList.get(y).get(rightX);
                            ElementalBondsBlockLogic.exchange(blockList, x, y, rightX, y, null);
                            List<ElementalBondsBlock> elementalBondsBlockList = ElementalBondsBlockLogic.getSameColorList(blockList, elementalBondsBlock);
                            List<ElementalBondsBlock> rightElementalBondsBlockList = ElementalBondsBlockLogic.getSameColorList(blockList, rightElementalBondsBlock);
                            if (!elementalBondsBlockList.isEmpty() || !rightElementalBondsBlockList.isEmpty()) {

                                Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
                                if (!elementalBondsBlockList.isEmpty()) {
                                    elementalBondsBlockSet.addAll(elementalBondsBlockList);
                                }
                                if (!rightElementalBondsBlockList.isEmpty()) {
                                    elementalBondsBlockSet.addAll(rightElementalBondsBlockList);
                                }

                                movedElementalBondsBlockSet.addAll(elementalBondsBlockSet);
                                movedElementalBondsBlockSet.add(elementalBondsBlock);
                                movedElementalBondsBlockSet.add(rightElementalBondsBlock);

                                ElementalBondsOperateEffect elementalBondsOperateEffect = new ElementalBondsOperateEffect(this, 1);
                                elementalBondsOperateEffect.addElementalBondsBlock(elementalBondsBlock);
                                elementalBondsOperateEffect.addElementalBondsBlock(rightElementalBondsBlock);
                                elementalBondsOperateResult.addElementalBondsOperateEffect(elementalBondsOperateEffect);

                                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(ElementalBondsEffectType.HIGH_LIGHT, new ArrayList<>(elementalBondsBlockSet)));
                                moveTimes++;
                                continue;
                            } else {
                                ElementalBondsBlockLogic.exchange(blockList, x, y, rightX, y, null);
                            }
                        }

                        // 跟上边交换
                        int upY = y + 1;
                        if (ElementalBondsBlockLogic.exist(blockList, x, upY) && !movedElementalBondsBlockSet.contains(blockList.get(upY).get(x))) {
                            ElementalBondsBlock upElementalBondsBlock = blockList.get(upY).get(x);
                            ElementalBondsBlockLogic.exchange(blockList, x, y, x, upY, null);
                            List<ElementalBondsBlock> elementalBondsBlockList = ElementalBondsBlockLogic.getSameColorList(blockList, elementalBondsBlock);
                            List<ElementalBondsBlock> upElementalBondsBlockList = ElementalBondsBlockLogic.getSameColorList(blockList, upElementalBondsBlock);
                            if (!elementalBondsBlockList.isEmpty() || !upElementalBondsBlockList.isEmpty()) {

                                Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();
                                if (!elementalBondsBlockList.isEmpty()) {
                                    elementalBondsBlockSet.addAll(elementalBondsBlockList);
                                }
                                if (!upElementalBondsBlockList.isEmpty()) {
                                    elementalBondsBlockSet.addAll(upElementalBondsBlockList);
                                }

                                movedElementalBondsBlockSet.addAll(elementalBondsBlockSet);
                                movedElementalBondsBlockSet.add(elementalBondsBlock);
                                movedElementalBondsBlockSet.add(upElementalBondsBlock);

                                ElementalBondsOperateEffect elementalBondsOperateEffect = new ElementalBondsOperateEffect(this, 1);
                                elementalBondsOperateEffect.addElementalBondsBlock(elementalBondsBlock);
                                elementalBondsOperateEffect.addElementalBondsBlock(upElementalBondsBlock);
                                elementalBondsOperateResult.addElementalBondsOperateEffect(elementalBondsOperateEffect);

                                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(ElementalBondsEffectType.HIGH_LIGHT, new ArrayList<>(elementalBondsBlockSet)));
                                moveTimes++;
                            } else {
                                ElementalBondsBlockLogic.exchange(blockList, x, y, x, upY, null);
                            }
                        }

                    }
                }

                if (curSize == movedElementalBondsBlockSet.size()) {
                    break;
                }
            }

            return Collections.emptySet();
        }
    },
    SKILL_1010(1010, "炸弹运送", "效果1：生成的炸弹格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            List<ElementalBondsBlock> elementalBondsBlockList = blockList.get(blockList.size() / 2);
            ElementalBondsBlock elementalBondsBlock = elementalBondsBlockList.get(elementalBondsBlockList.size() / 2);
            int baseX = elementalBondsBlock.getX();
            int baseY = elementalBondsBlock.getY();

            Set<ElementalBondsBlock> elementalBondsBlockSet = new HashSet<>();

            // 该位置如果是百宝箱，则选择该位置附近的格子
            int[][] xy = new int[][]{
                    {0, -1}, // 下
                    {-1, -1}, // 左下
                    {-1, 0}, // 左
                    {-1, 1}, // 左上
                    {0, 1}, // 上
                    {1, 1}, // 右上
                    {1, 0}, // 右
                    {1, -1}, // 右下
            };
            int index = 0;
            while (elementalBondsBlock.getElementalBondsBlockType() == ElementalBondsBlockType.BAI_BAO_XIANG && index < xy.length) {
                elementalBondsBlock = blockList.get(baseY + xy[index][1]).get(baseX + xy[index][0]);
                index++;
            }
            if (index < xy.length) {
                // 红釉青花特殊处理
                int color = elementalBondsSkillParam.getSide() == 1 ? ElementalBondsColorType.RED.getType() : ElementalBondsColorType.BLUE.getType();
                ElementalBondsSceneLogic.scene_08_changeColor(elementalBondsGameData, color);

                // 修改
                elementalBondsBlock.setElementalBondsBlockType(ElementalBondsBlockType.LANDMINE);

                // 技能效果
                elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, Collections.singletonList(elementalBondsBlock)));

                elementalBondsBlockSet.add(elementalBondsBlock);
            }
            return elementalBondsBlockSet;
        }
    },
    SKILL_1011(1011, "传送", "效果1：交换后的格子") {
        @Override
        public int check(ElementalBondsGameData elementalBondsGameData, ElementalBondsSkillParam elementalBondsSkillParam, ElementalBondsOperateResult elementalBondsOperateResult) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            if (!ElementalBondsBlockLogic.exist(blockList, elementalBondsSkillParam)) {
                return GameErrorCode.E_ELEMENTAL_BONDS_POS_NO_EXIST;
            }
            if (elementalBondsSkillParam.getFromX() == elementalBondsSkillParam.getToX() && elementalBondsSkillParam.getFromY() == elementalBondsSkillParam.getToY()) {
                return GameErrorCode.E_ELEMENTAL_BONDS_BLOCK_CAN_NOT_CHOOSE;
            }
            int ret = ElementalBondsSceneLogic.scene_07_checkChooseBlock(elementalBondsGameData, elementalBondsSkillParam, true);
            if (ret != GameErrorCode.E_SUCCESS_VALUE) {
                return ret;
            }
            return ElementalBondsCardLogic.check_23(elementalBondsGameData, elementalBondsSkillParam);
        }

        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();
            ElementalBondsBlock fromElementalBondsBlock = blockList.get(elementalBondsSkillParam.getFromY()).get(elementalBondsSkillParam.getFromX()).clone();
            fromElementalBondsBlock.setX(elementalBondsSkillParam.getToX());
            fromElementalBondsBlock.setY(elementalBondsSkillParam.getToY());
            ElementalBondsBlock toElementalBondsBlock = blockList.get(elementalBondsSkillParam.getToY()).get(elementalBondsSkillParam.getToX()).clone();
            toElementalBondsBlock.setX(elementalBondsSkillParam.getFromX());
            toElementalBondsBlock.setY(elementalBondsSkillParam.getFromY());

            // 替换
            blockList.get(fromElementalBondsBlock.getY()).set(fromElementalBondsBlock.getX(), fromElementalBondsBlock);
            blockList.get(toElementalBondsBlock.getY()).set(toElementalBondsBlock.getX(), toElementalBondsBlock);

            List<ElementalBondsBlock> elementalBondsBlockList = new ArrayList<>();
            elementalBondsBlockList.add(fromElementalBondsBlock);
            elementalBondsBlockList.add(toElementalBondsBlock);

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, elementalBondsBlockList));

            return Collections.emptySet();
        }
    },
    SKILL_1012(1012, "制造钻石", "效果1：生成的钻石格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            // 参数
            long num = elementalBondsSkillConfig.getSkillParamList().get(0);

            int color = elementalBondsSkillParam.getSide() == 1 ? ElementalBondsColorType.RED.getType() : ElementalBondsColorType.BLUE.getType();
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            // 拿可选方块
            List<ElementalBondsBlock> randomElementalBondsBlockList = new ArrayList<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    if (elementalBondsBlock.getColor() != color && elementalBondsBlock.getElementalBondsBlockType() == ElementalBondsBlockType.NORMAL) {
                        randomElementalBondsBlockList.add(elementalBondsBlock);
                    }
                }
            }
            // 打乱
            Collections.shuffle(randomElementalBondsBlockList, random);

            // 取方块变色
            List<ElementalBondsBlock> elementalBondsBlockList = new ArrayList<>();
            for (int i = 0; i < num && i < randomElementalBondsBlockList.size(); i++) {
                ElementalBondsBlock elementalBondsBlock = randomElementalBondsBlockList.get(i);
                elementalBondsBlock.setColor(color);
                ElementalBondsSceneLogic.scene_12_checkEffectChange(elementalBondsBlock, elementalBondsGameData);
                elementalBondsBlockList.add(elementalBondsBlock);
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, elementalBondsBlockList));

            return Collections.emptySet();
        }
    },
    SKILL_1013(1013, "引爆器", "效果1：引爆的炸弹格子") {
        @Override
        public Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                            ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                            Random random, int roomRound, int turnPlayer) {
            List<List<ElementalBondsBlock>> blockList = elementalBondsGameData.getBlockList();

            List<ElementalBondsBlock> chooseElementalBondsBlockList = new ArrayList<>();
            for (List<ElementalBondsBlock> elementalBondsBlockList : blockList) {
                for (ElementalBondsBlock elementalBondsBlock : elementalBondsBlockList) {
                    if (elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.NORMAL_BOMB
                            || elementalBondsBlock.getElementalBondsBlockType().getBigType() == ElementalBondsBlockBigType.SPECIAL_BOMB) {
                        chooseElementalBondsBlockList.add(elementalBondsBlock);
                    }
                }
            }

            // 技能效果
            elementalBondsOperateResult.addElementalBondsOperateEffect(new ElementalBondsOperateEffect(this, 1, chooseElementalBondsBlockList));

            return new HashSet<>(chooseElementalBondsBlockList);
        }
    },
    ;

    private final int type;
    private final String desc;
    private final String detail;

    ElementalBondsSkillType(int type, String desc, String detail) {
        this.type = type;
        this.desc = desc;
        this.detail = detail;
    }

    public static ElementalBondsSkillType forType(int type) {
        return Arrays.stream(ElementalBondsSkillType.values())
                .filter(elementalBondsSkillType -> elementalBondsSkillType.getType() == type)
                .findFirst()
                .orElse(NONE);
    }

    public int getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public String getDetail() {
        return detail;
    }

    public int check(ElementalBondsGameData elementalBondsGameData, ElementalBondsSkillParam elementalBondsSkillParam, ElementalBondsOperateResult elementalBondsOperateResult) {
        return GameErrorCode.E_SUCCESS_VALUE;
    }

    public abstract Set<ElementalBondsBlock> use(ElementalBondsSkillConfig elementalBondsSkillConfig, ElementalBondsSkillParam elementalBondsSkillParam,
                                                 ElementalBondsGameData elementalBondsGameData, ElementalBondsOperateResult elementalBondsOperateResult, ElementalBondsPlayerData elementalBondsPlayerData,
                                                 Random random, int roomRound, int turnPlayer);

}
